package com.oil.petro.eshop.validator;

import com.oil.petro.eshop.bean.ProductBean;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

@Component
public class ProductValidator {

    private final String numberPattern = "(\\d*)";

    public boolean hasErrors(ProductBean productBean) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

       // ProductBean productBean = (ProductBean) o;
        if (productBean.getOrderedQuantity().equals("")) {
            return true;
        }

        if (!productBean.getOrderedQuantity().matches(numberPattern)) {
            return true;
        }

        return false;
    }

}
